package com.heima.utils.common;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.awt.image.BufferedImage;

//图片文字识别
public class Tess4j {
    private static final String PATH="D:\\BaiduNetdiskDownload\\tessdata";
    private static final String LANG="chi_sim";

    public static String tess4j(BufferedImage file) throws TesseractException {
        ITesseract tesseract = new Tesseract();
        tesseract.setDatapath(PATH);
        tesseract.setLanguage(LANG);
        String doOCR = tesseract.doOCR(file);
        return doOCR;
    }
}
